package com.yuexunit.mobilenurse.module.DocAdvice.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yuexunit.mobilenurse.R;
import com.yuexunit.mobilenurse.module.DocAdvice.bean.DocAdvice_OrderDetail;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/5/8 0008.
 */

public class OutMedicineListListAdapter extends BaseAdapter {
    private Context context;
    //    protected LayoutInflater mInflater;
    private ArrayList<DocAdvice_OrderDetail> mDatas;

    public OutMedicineListListAdapter(Context context, ArrayList<DocAdvice_OrderDetail> mDatas) {
        this.context = context;
        this.mDatas = mDatas;
    }


    @Override
    public int getCount() {
        return null == mDatas ? 0 : mDatas.size();
//        return 3;
    }

    @Override
    public Object getItem(int position) {
        return null == mDatas ? null : mDatas.get(position);
//        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        OutMedicineListListAdapter.ViewHolder holder;
        if (null == convertView) {
            convertView = LayoutInflater.from(context).inflate(R.layout.injectionlist_itemlist, parent, false);
            holder = new OutMedicineListListAdapter.ViewHolder();
            holder.injection_list_item_name = (TextView) convertView.findViewById(R.id.injection_list_item_name);
            holder.injection_list_item_dosage = (TextView) convertView.findViewById(R.id.injection_list_item_dosage);

            convertView.setTag(holder);
        } else {
            holder = (OutMedicineListListAdapter.ViewHolder) convertView.getTag();
        }

        holder.injection_list_item_name.setText(mDatas.get(position).getMedname());
//        holder.injection_list_item_dosage.setText(mDatas.get(position).getDosage()+mDatas.get(position).getDoseusnit());
        holder.injection_list_item_dosage.setText(mDatas.get(position).getDosage() + "" +
                "");

        return convertView;
    }

    class ViewHolder {
        TextView injection_list_item_name, injection_list_item_dosage;
    }
}
